from typing import List


class Solution:

    def __init__(self):
        self.ans = 0
        self.nums = []

    def subsetXORSum(self, nums: List[int]) -> int:
        self.nums = nums
        for i in range(len(self.nums) + 1):
            self.dfs(i, 0)
        return self.ans

    def dfs(self, i, now):
        if i == len(self.nums):
            self.ans += now
        else:
            now ^= self.nums[i]
            for j in range(i + 1, len(self.nums) + 1):
                self.dfs(j, now)


if __name__ == "__main__":
    print(Solution().subsetXORSum([1, 3]))  # 6
    print(Solution().subsetXORSum([5, 1, 6]))  # 28
    print(Solution().subsetXORSum([3, 4, 5, 6, 7, 8]))  # 480
